#!/bin/bash

# 确保日志和进程文件目录存在
mkdir -p /www/wwwroot/TravelAgentAPI/logs
mkdir -p /www/wwwroot/TravelAgentAPI/run

# 切换到项目目录
cd /www/wwwroot/TravelAgentAPI

# 直接设置环境变量
export DB_HOST=120.78.7.85
export DB_USER=ljy
export DB_PASSWORD=Lijinyuan,.1983
export DB_NAME=travel_agent
export DB_CHARSET=utf8mb4
export PYTHONPATH=/www/wwwroot/TravelAgentAPI:$PYTHONPATH

# 启动服务
/www/server/pyporject_evn/TravelAgentAPI_venv/bin/gunicorn main:app -c gunicorn.conf.py

# 检查启动状态
sleep 2
if [ -f /www/wwwroot/TravelAgentAPI/run/gunicorn_8003.pid ]; then
    echo "Service started successfully"
else
    echo "Service failed to start"
fi 